<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //快速获取resovle和reject状态promise实例的方法

        //成功
        //同步
        // var p = Promise.resolve(1)
        // console.log(p);

        //异步
        var p = Promise.resolve({
            then: function (resolve, reject) {
                setTimeout(function () {
                    resolve(1111);

                }, 1000)
            }
        })
        p.then(function (val) {
            console.log(val);
        }).catch(function (err) {
            console.log(err);
        })

        //失败
        // var p = Promise.reject(err)

    </script>
</body>

</html>